<%--
  Created by IntelliJ IDEA.
  User: 袁飞
  Date: 2020/3/11/011
  Time: 20:17
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>华晨机械公司erp系统|进销存</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bssmanager/plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bssmanager/dist/css/adminlte.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bssmanager/plugins/toastr/toastr.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bssmanager/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <jsp:include page="../navbar.jsp"></jsp:include>
    <jsp:include page="../sidebar.jsp"></jsp:include>
    <div class="content-wrapper">
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">Starter Page</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">Starter Page</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
<div class="content contents">
    <div class="container-fluid">
        <div class="row">
            <section class="content">
                <div class="container-fluid">
                    <div class="card-header">
                        <h3 class="card-title">订单列表</h3>
                    </div>
                    <div class="card-body">
                        <table class="table table-bproducted">
                            <thead>
                            <tr>
                                <th style="width: 10px">id</th>
                                <th>类目</th>
                                <th>商品名称</th>
                                <th>价格</th>
                                <th>库存</th>
                                <th>描述</th>
                                <th>创建时间</th>
                                <th>更新时间</th>
                                <th style="" colspan="2">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${pageInfo.list}" var="product">
                                    <tr>
                                        <td>${product.productId}</td>
                                        <td>${product.categoryType}</td>
                                        <td>${product.productName}</td>
                                        <td>${product.productPrice}</td>
                                        <td>${product.productStock}</td>
                                        <td>${product.productDescription}</td>
                                        <td><fmt:formatDate value="${product.createTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                                        <td><fmt:formatDate value="${product.updateTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                                        <td><button type='button' class='btn btn-block bg-gradient-primary' data-toggle="modal" data-target="#modal-default" >
                                                <a href="javascript:editproduct(${product.productId});" style="color: #fff;">出售</a>
                                        </button></td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                    </div>
                    <div class="card-footer clearfix">
                        <ul class="pagination pagination-sm m-0 float-right" id="paging">
                            <li class='page-item disabled'><a class='page-link' href='javascript:void(0);'>&laquo;</a></li>
                            <c:forEach begin="1" end="${pageInfo.pages}" step="1" var="p">
                                <li class='page-item'><a class='page-link' href='/ERP/bss/sales/salesProduct?pageNum=${p}' >${p}</a></li>
                            </c:forEach>
                            <li class='page-item disabled'><a class='page-link' href='javascript:void(0);'>&raquo;</a></li>
                        </ul>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
    <div class="modal fade" id="modal-default" style="display: none;" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">商品信息</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true"><p class="nav-icon fas fa-window-close"></p></span>
                    </button>
                </div>
                <form role="form" id="myForm">
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="productName">productName</label>
                            <input type="text" class="form-control" id="productName" name="productName" placeholder="productName">
                        </div>
                        <div class="form-group">
                            <label for="saleName">SaleName</label>
                            <select class="form-control" id="saleName" name="saleName">
                                <c:forEach items="${customerList}" var="customer">
                                    <option value="${customer.customerName}">${customer.customerName}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="saleCount">saleCount</label>
                            <input type="text" class="form-control" id="saleCount" name="saleCount" placeholder="saleCount">
                        </div>
                    </div>
                    <div class="modal-footer justify-content-between">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-success swalDefaultSuccess" id="salesProductSuccess" data-dismiss="modal">出售</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <jsp:include page="../controlsidebar.jsp"></jsp:include>
    <jsp:include page="../foot.jsp"></jsp:include>
    <div id="sidebar-overlay"></div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/bssmanager/plugins/jquery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/bssmanager/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="${pageContext.request.contextPath}/bssmanager/dist/js/adminlte.min.js"></script>
<script src="${pageContext.request.contextPath}/bssmanager/dist/js/demo.js"></script>
<script src="${pageContext.request.contextPath}/bssmanager/plugins/sweetalert2/sweetalert2.min.js"></script>
<script src="${pageContext.request.contextPath}/bssmanager/plugins/toastr/toastr.min.js"></script>
<script>
    var Toast = Swal.mixin({
        toast: true,
        position: 'center',
        showConfirmButton: false,
        timer: 3000
    });
    function editproduct(id){
        $.get({
            url:'/ERP/bss/product/find?id='+id,
            async:false,
            success:function (data) {
                $("#productName").val(data.productName);
            }
        })
    }
    $(function () {
        $("#salesProductSuccess").click(function() {
            alert("111")
            $.post({
                url:'/ERP/bss/sales/add',
                data:$("#myForm").serialize(),
                success:function () {
                    Toast.fire({
                        type: 'success',
                        title: 'congratulation you success!'
                    })
                    setTimeout('location.href="/ERP/bss/sales/salesProduct"',6000);
                }
            })
        });
        $(".selected-title").each(function () {
            $(this).on("click",function () {
                if ($(this).hasClass("active")) {
                    return
                }else {
                    $(".selected-title").each(function () {
                        $(this).removeClass("active")
                    })
                    $(this).addClass("active")
                }
            })
        })
        $(".selectedA").each(function(){
            $(this).on("click",function () {
                if ($(this).hasClass("active")) {
                }else {
                    $(".selectedA").each(function () {
                        $(this).removeClass("active")
                    })
                    $(this).addClass("active")
                    var pre=$(this).attr("name")
                    $.ajax({
                        type: "GET",
                        async:false,
                        url: $(this).attr("action"),
                        cache:false,
                        success: function (data) {
                            $(".content").html(data)
                            $.getScript(pre+'list.js',function(){
                            });
                        }
                    })
                }
            })
        })
    })
</script>
</body>
</html>
